package com.ufaud.ais.sys.webapp.action;

import com.ufaud.ais.pub.webapp.action.JQueryTreeViewAction;
import com.ufaud.ais.sys.entity.MenuItem;
import com.ufaud.ais.sys.service.IMenuItemService;

public class MenuTreeAction extends JQueryTreeViewAction<MenuItem> {
	
	private IMenuItemService menuItemService;
	
	public String getTree() throws Exception {
		putUrl("查看", "${ctx}/sys/menu/toAction/view.action?id=${id}");
		putUrl("删除", "javascript:ajaxDelete('${ctx}/ajax/menu/doDelete.action?id=${id}', '是否确认删除菜单【${text}】?')");
		return execute();
	}

	@Override
	protected String getChildrenFieldName() {
		return "subMenuItemList";
	}

	@Override
	protected String getIdFieldName() {
		return "menuItemId";
	}

	@Override
	protected String getTextFieldName() {
		return "menuItemName";
	}

	@Override
	protected MenuItem loadActualObject() {
		return menuItemService.getAllMenuItemInTreeStructure();
	}

	public void setMenuItemService(IMenuItemService menuItemService) {
		this.menuItemService = menuItemService;
	}

}
